<?php

use app\assets\ApiAsset;
use app\assets\LayerAsset;
use app\assets\TableAsset;
use app\widgets\LinkPager;
use app\widgets\ManagerTableOp;
use yii\helpers\Html;
use yii\helpers\Url;
use app\models\KeyMap;
use dosamigos\datepicker\DatePicker;
/**
 * @var $this yii\web\View
 * @var $profitList app\models\AgentProfit[]
 * @var $pagination yii\data\Pagination
 */

ApiAsset::register($this);
LayerAsset::register($this);
TableAsset::register($this);

$this->title = '资金变动列表';
$this->params['breadcrumbs'][] = '财务管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php echo Html::beginForm('?', 'get', ['class'=>'form-inline']);?>
<div class="form-group">
    <label for="search_trade_no" class="sr-only">Trade_no</label>
    <?php echo Html::textInput('search_trade_no', Yii::$app->request->get('search_trade_no'), ['id'=>'search_trade_no', 'class'=>'form-control', 'placeholder'=>'搜索订单号', 'style' => 'width:120px;']);?>
</div>
<div class="form-group">
    <label for="search_source">资金变动类型</label>
    <?php echo Html::dropDownList('search_source', Yii::$app->request->get('search_source'), ['2'=>'代理商充值','4'=>'API订购'], ['id' => 'search_source', 'class' => 'form-control', 'prompt' => '资金变动']);?>
</div>
<div class="form-group">
    <label for="time">起始时间</label>
    <?php echo DatePicker::widget([ 
        'name' => 'search_start_time', 
        'options' => ['placeholder' => '时间'], 
        'attribute' => 'time',
        'template' => '{addon}{input}',
        'value' => $search_start_time,
        'clientOptions' => [ 
            'autoclose' => true, 
            'format' => 'yyyy-mm-dd',
            'todayHighlight' => true, 
        ] 
    ]); ?>
</div>
<div class="form-group">
    <label for="time">结束时间</label>
    <?php echo DatePicker::widget([ 
        'name' => 'search_end_time', 
        'options' => ['placeholder' => '时间'], 
        'attribute' => 'time',
        'template' => '{addon}{input}',
        'value' => $search_end_time,
        'clientOptions' => [ 
            'autoclose' => true, 
            'format' => 'yyyy-mm-dd',
            'todayHighlight' => true, 
        ] 
    ]); ?>
</div>
<div class="form-group">
    <button class="btn btn-primary btn-sm">搜索</button>
    <a href="<?php echo Url::current(['export'=>'excel']);?>">导出Excel</a>
    <a href="<?php echo Url::current(['export'=>'csv']);?>">导出CSV</a>
</div>
<?php echo Html::endForm();?>
<table class="table table-striped table-bordered table-hover">
    <thead>
    <tr>
        <th class="center">
            <label class="pos-rel">
               
                <span class="lbl">编号</span>
            </label>
        </th>
        <th class="center">姓名</th>
        <th class="center">资金变化</th>
        <th class="center">余额</th>
        <th class="center">充值号码</th>
        <th class="center">订单号</th>
        <th class="center">创建时间</th>
        <th class="center">资金来源</th>
    </tr>
    </thead>

    <tbody>
    <?php foreach ($moneychangeList as $moneychange) {?>
        <tr>
            <td class="center"><?php echo $moneychange->id?></td>
            <td class="center"><?php echo $moneychange->agent->username;?></td>
            <td class="center"><?php echo $moneychange->money_change;?></td>
            <td class="center"><?php echo $moneychange->left_money;?></td>
            <td class="center"><?php echo $moneychange->recharge_number;?></td>
            <td class="center"><?php echo $moneychange->order_no;?></td>
            <td class="center"><?php echo Yii::$app->formatter->asDatetime($moneychange->create_time);?></td>
            <td class="center"><?php echo KeyMap::getValue('money_source', $moneychange->money_source);?></td>
        </tr>
    <?php }?>
    </tbody>
</table>
<?php echo LinkPager::widget(['pagination' => $pagination]);?>
